*for REStat paper "Breastfeeding and Children's Early Cognitive Outcomes"
libname dd 'X:\Donnanew';

data dd.pfam083;
  set dd.pfam082;

**now, let's just get a few characteristics from the family file for pcg97=1 and her family;
keep childid regne regnc regw regs pcgbl pcghi faminc97 pcg97id;


**region for year of birth;
if childyob = 1983 then do;
regne = regne83;
regnc = regnc83;
regw = regw83;
regs = regs83;
end;
if childyob = 1984 then do;
regne = regne84;
regnc = regnc84;
regw = regw84;
regs = regs84;
end;
if childyob = 1985 then do;
regne = regne85;
regnc = regnc85;
regw = regw85;
regs = regs85;
end;
if childyob = 1986 then do;
regne = regne86;
regnc = regnc86;
regw = regw86;
regs = regs86;
end;
if childyob = 1987 then do;
regne = regne87;
regnc = regnc87;
regw = regw87;
regs = regs87;
end;
if childyob = 1988 then do;
regne = regne88;
regnc = regnc88;
regw = regw88;
regs = regs88;
end;
if childyob = 1989 then do;
regne = regne89;
regnc = regnc89;
regw = regw89;
regs = regs89;
end;
if childyob = 1990 then do;
regne = regne90;
regnc = regnc90;
regw = regw90;
regs = regs90;
end;
if childyob = 1991 then do;
regne = regne91;
regnc = regnc91;
regw = regw91;
regs = regs91;
end;
if childyob = 1992 then do;
regne = regne92;
regnc = regnc92;
regw = regw92;
regs = regs92;
end;
if childyob = 1993 then do;
regne = regne93;
regnc = regnc93;
regw = regw93;
regs = regs93;
end;
if childyob = 1994 then do;
regne = regne94;
regnc = regnc94;
regw = regw94;
regs = regs94;
end;
if childyob = 1995 then do;
regne = regne95;
regnc = regnc95;
regw = regw95;
regs = regs95;
end;
if childyob = 1996 then do;
regne = regne96;
regnc = regnc96;
regw = regw96;
regs = regs96;
end;
if childyob = 1997 then do;
regne = regne97;
regnc = regnc97;
regw = regw97;
regs = regs97;
end;
if regne = 1 then do;
regnc = 0;
regw = 0;
regs = 0;
end;
if regnc = 1 then do;
regne = 0;
regw = 0;
regs = 0;
end;
if regw = 1 then do;
regnc = 0;
regne = 0;
regs = 0;
end;
if regs = 1 then do;
regnc = 0;
regw = 0;
regne = 0;
end;

**I am going to . out ones that don't apply;
if hw96 = . then do;
hblack96 = .;
hhisp96 = .;
wblack96 = .;
whisp96 = .;
end;
if hw96 = 1 then do;
wblack96 = .;
whisp96 = .;
end;
if hw96 = 2 then do;
hblack96 = .;
hhisp96 = .;
end;
if hw95 = . then do;
hblack95 = .;
hhisp95 = .;
wblack95 = .;
whisp95 = .;
end;
if hw95 = 1 then do;
wblack95 = .;
whisp95 = .;
end;
if hw95 = 2 then do;
hblack95 = .;
hhisp95 = .;
end;
if hw94 = . then do;
hblack94 = .;
hhisp94 = .;
wblack94 = .;
whisp94 = .;
end;
if hw94 = 1 then do;
wblack94 = .;
whisp94 = .;
end;
if hw94 = 2 then do;
hblack94 = .;
hhisp94 = .;
end;
if hw93 = . then do;
hblack93 = .;
hhisp93 = .;
wblack93 = .;
whisp93 = .;
end;
if hw93 = 1 then do;
wblack93 = .;
whisp93 = .;
end;
if hw93 = 2 then do;
hblack93 = .;
hhisp93 = .;
end;
if hw92 = . then do;
hblack92 = .;
hhisp92 = .;
wblack92 = .;
whisp92 = .;
end;
if hw92 = 1 then do;
wblack92 = .;
whisp92 = .;
end;
if hw92 = 2 then do;
hblack92 = .;
hhisp92 = .;
end;
if hw91 = . then do;
hblack91 = .;
hhisp91 = .;
wblack91 = .;
whisp91 = .;
end;
if hw91 = 1 then do;
wblack91 = .;
whisp91 = .;
end;
if hw91 = 2 then do;
hblack91 = .;
hhisp91 = .;
end;
if hw90 = . then do;
hblack90 = .;
hhisp90 = .;
wblack90 = .;
whisp90 = .;
end;
if hw90 = 1 then do;
wblack90 = .;
whisp90 = .;
end;
if hw90 = 2 then do;
hblack90 = .;
hhisp90 = .;
end;
if hw89 = . then do;
hblack89 = .;
hhisp89 = .;
wblack89 = .;
whisp89 = .;
end;
if hw89 = 1 then do;
wblack89 = .;
whisp89 = .;
end;
if hw89 = 2 then do;
hblack89 = .;
hhisp89 = .;
end;
if hw88 = . then do;
hblack88 = .;
hhisp88 = .;
wblack88 = .;
whisp88 = .;
end;
if hw88 = 1 then do;
wblack88 = .;
whisp88 = .;
end;
if hw88 = 2 then do;
hblack88 = .;
hhisp88 = .;
end;
if hw87 = . then do;
hblack87 = .;
hhisp87 = .;
wblack87 = .;
whisp87 = .;
end;
if hw87 = 1 then do;
wblack87 = .;
whisp87 = .;
end;
if hw87 = 2 then do;
hblack87 = .;
hhisp87 = .;
end;
if hw86 = . then do;
hblack86 = .;
hhisp86 = .;
wblack86 = .;
whisp86 = .;
end;
if hw86 = 1 then do;
wblack86 = .;
whisp86 = .;
end;
if hw86 = 2 then do;
hblack86 = .;
hhisp86 = .;
end;
if hw85 = . then do;
hblack85 = .;
hhisp85 = .;
wblack85 = .;
whisp85 = .;
end;
if hw85 = 1 then do;
wblack85 = .;
whisp85 = .;
end;
if hw85 = 2 then do;
hblack85 = .;
hhisp85 = .;
end;
**now should be able to code ever race/ethnicity;
pcgbl = .;
pcghi = .;
if (hhisp85 = 1 or hhisp86 = 1 or hhisp87 = 1 or hhisp88 = 1 or hhisp89 = 1 or hhisp90 = 1 or hhisp91 = 1 or hhisp92 = 1
   or hhisp93 = 1 or hhisp94 = 1 or hhisp95 = 1 or hhisp96 = 1 or
    whisp85 = 1 or whisp86 = 1 or whisp87 = 1 or whisp88 = 1 or whisp89 = 1 or whisp90 = 1 or whisp91 = 1 or whisp92 = 1
   or whisp93 = 1 or whisp94 = 1 or whisp95 = 1 or whisp96 = 1) then pcghi = 1;
if (hblack85 = 1 or hblack86 = 1 or hblack87 = 1 or hblack88 = 1 or hblack89 = 1 or hblack90 = 1 or hblack91 = 1 or hblack92 = 1
   or hblack93 = 1 or hblack94 = 1 or hblack95 = 1 or hblack96 = 1 or
    wblack85 = 1 or wblack86 = 1 or wblack87 = 1 or wblack88 = 1 or wblack89 = 1 or wblack90 = 1 or wblack91 = 1 or wblack92 = 1
   or wblack93 = 1 or wblack94 = 1 or wblack95 = 1 or wblack96 = 1) then pcgbl = 1;
if pcghi = 1 then pcgbl = 0;
if pcgbl = 1 then pcghi = 0;
if (pcghi = . and pcgbl = .) then do;
if ((hhisp85 = 0 and hblack85 = 0) or (whisp85 = 0 and wblack85 = 0) or 
    (hhisp86 = 0 and hblack86 = 0) or (whisp86 = 0 and wblack86 = 0) or
    (hhisp87 = 0 and hblack87 = 0) or (whisp87 = 0 and wblack87 = 0) or
    (hhisp88 = 0 and hblack88 = 0) or (whisp88 = 0 and wblack88 = 0) or
    (hhisp89 = 0 and hblack89 = 0) or (whisp89 = 0 and wblack89 = 0) or
    (hhisp90 = 0 and hblack90 = 0) or (whisp90 = 0 and wblack90 = 0) or
    (hhisp91 = 0 and hblack91 = 0) or (whisp91 = 0 and wblack91 = 0) or
    (hhisp92 = 0 and hblack92 = 0) or (whisp92 = 0 and wblack92 = 0) or
    (hhisp93 = 0 and hblack93 = 0) or (whisp93 = 0 and wblack93 = 0) or
    (hhisp94 = 0 and hblack94 = 0) or (whisp94 = 0 and wblack94 = 0) or
    (hhisp95 = 0 and hblack95 = 0) or (whisp95 = 0 and wblack95 = 0) or
    (hhisp96 = 0 and hblack96 = 0) or (whisp96 = 0 and wblack96 = 0)) then do;
	pcgbl = 0;
	pcghi = 0;
end;
end;
**will likely use child race to fill in missings...;





proc means;
run;
